package messenger;

import java.net.*;

public class GenericServer {
    private ServerSocket serverSocket;
        
    public GenericServer(int port){
        try{
            serverSocket = new ServerSocket(port);
        }catch(Exception e){e.printStackTrace();}
        Thread t = new Thread(new EsperaConexao());
        t.start();
    }

    public ServerSocket getServerSocket() {
        return serverSocket;
    }
    
    public class EsperaConexao implements Runnable{
        public void run() {
            try{
                while(true){
                    Socket client = serverSocket.accept();
                    new ChatConnection(client);
                }    
            }catch(Exception e){e.printStackTrace();}
        }     
    }    
}
